import { KnowledgeParams,KnowledgePage,PageParams,DoctorPage,FollowType, TopDep, Image, ConsultOrderPreParams, ConsultOrderPreData, PartialConsult, ConsultOrderItem } from "@/types/consult";
import { request } from "@/utils/request";

export const getKnowledgePage=(params:KnowledgeParams)=>
  request<KnowledgePage>('patient/home/knowledge','get',params)

export const getDoctorPage=(params:PageParams)=>
  request<DoctorPage>('home/page/doc','get',params)

export const followOrUnfollow=(id:string,type:FollowType='doc')=>
  request('like','post',{id,type})

export const getAllDep=()=>
  request<TopDep[]>('dep/all')
//图片上传
export const uploadImage=(file:File)=>{
  const fd=new FormData()
  fd.append('file',file)
  return request<Image>('upload','post',fd)
}
//预支付信息获取
export const getConsultOrderPre=(params:ConsultOrderPreParams)=>
  request<ConsultOrderPreData>('/patient/consult/order/pre','get' ,params)
//生成订单
export const createConsultOrder=(data:PartialConsult)=>
  request<{id:string}>('/patient/consult/order','post',data)
//支付订单
export const getConsultOrderPayUrl=(params:{
  paymentMethod:1|0,
  orderId:string,
  payCallback:string
})=>request<{payUrl:string}>('patient/consult/pay','post',params)
//获取订单详情
export const getConsultOrderDetail=(orderId:string)=>
  request<ConsultOrderItem>('patient/consult/order/detail','get',{orderId})


